* Add gun ownership and culture proxies to regressions

set more off

// 5-year rolling average of cook index  {{{
capture confirm file "`out'/cook.dta"
if _rc {
    qui rolling mucook=r(mean), win(5) saving(`out'/cook, replace): /*
        */ sum cook, meanonly
}
cap drop mucook end
gen int end = year
merge 1:1 fips end using "`out'/cook.dta", keep(1 3) nogen keepusing(mucook)
la var mucook "Five-year rolling mean percent of suicides with gun"
drop end
// }}}

// shooting interactions  {{{
cap drop shootXcook
sort fips year
gen float shootXcook = L.`shoot' * mucook
la var shootXcook "Shooting X Cook"

cap drop shootXhunt
gen float shootXhunt = L.`shoot' * hunters
// }}}


// regressions  {{{
loc svars "shootXdemleg shootXrepleg shootXsplleg"

foreach dv in laws_tighten laws_loosen {
    eststo clear
    loc m = 1

    // percent suicides with gun
    xtpoisson `dv' `svars' mucook `controls' `rng', `opt'
    qui estadd local sfix = "Yes"
    if regexm("`controls'", "i\.year") qui estadd local yfix "Yes"
    eststo c`m', title("`dv'")
    loc m = `m' + 1

    xtpoisson `dv' `svars' shootXcook mucook `controls' `rng', `opt'
    qui estadd local sfix = "Yes"
    if regexm("`controls'", "i\.year") qui estadd local yfix "Yes"
    eststo c`m', title("`dv'")
    loc m = `m' + 1

    xtpoisson `dv' shootXcook mucook `controls' `rng', `opt'
    qui estadd local sfix = "Yes"
    if regexm("`controls'", "i\.year") qui estadd local yfix "Yes"
    eststo c`m', title("`dv'")
    loc m = `m' + 1

    // hunting population
    xtpoisson `dv' `svars' hunters `controls' `rng', `opt'
    qui estadd local sfix = "Yes"
    if regexm("`controls'", "i\.year") qui estadd local yfix "Yes"
    eststo c`m', title("`dv'")
    loc m = `m' + 1

    xtpoisson `dv' `svars' shootXhunt hunters `controls' `rng', `opt'
    qui estadd local sfix = "Yes"
    if regexm("`controls'", "i\.year") qui estadd local yfix "Yes"
    eststo c`m', title("`dv'")
    loc m = `m' + 1

    xtpoisson `dv' shootXhunt hunters `controls' `rng', `opt'
    qui estadd local sfix = "Yes"
    if regexm("`controls'", "i\.year") qui estadd local yfix "Yes"
    eststo c`m', title("`dv'")
    loc m = `m' + 1

    // save tables
    writemodel c* using "`out'/cook_regs_`dv'", drop(*.year) ext(csv) /*
        */ order(`svars' shootXcook mucook shootXhunt hunters)
}  // }}}

exit
// vim: foldmethod=marker
